package com.lxy.ikunoj.code;

import org.springframework.boot.test.context.SpringBootTest;

import java.util.Arrays;


/**
 * @ClassName CodeTest
 * @Description TODO
 * @Author LXY
 * @Date 2024/1/3 13:31
 * @Version 1.0
 */
@SpringBootTest
public class CodeTest1 {

    public static void main(String[] args) {
        CodeTest1.Solution solution = new Solution();
        int[] nums = {2, 7, 11, 15};
        int target = 13;
        int[] ints = solution.twoSum(nums, target);

        System.out.print(Arrays.toString(ints));

    }

    static class Solution {
        public int[] twoSum(int[] nums, int target) {
            int n = nums.length;
            for (int i = 0; i < n; ++i) {
                for (int j = i + 1; j < n; ++j) {
                    if (nums[i] + nums[j] == target) {
                        return new int[]{i, j};
                    }
                }
            }
            return new int[0];
        }
    }


}
